// 代码题二
const _ = require('lodash')
const fp = require('lodash/fp')
// 2.1
fp.flowRight(fp.prop('in_stock'),fp.last(cars))

// 2.2
fp.flowRight(fp.prop('name'),fp.first(cars))

// 2.3
let _average = function(xs){
    return fp.reduce(fp.add,0,xs)/xs.length
}
let dollar_values = function(cars){return fp.map(function(car){return car.dollar_value},cars)} 
let averageDollarValue = fp.flowRight(_average, dollar_values(cars))

//2.4
let _underscore = fp.replace(/\W+/g,'_')
let str = 'Hello World'
const sanitizeNames = fp.flowRight(_underscore(),fp.split(' '), fp.toLower)
console.log(sanitizeNames(str))


